/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.chart.AOrdinarySalesTypeParam;
import com.thor.palmmall.spi.chart.SOrdinarySalesTypeParam;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class SOrdinarySalesTypeParamConverter
    implements Converter<AOrdinarySalesTypeParam, SOrdinarySalesTypeParam> {

  public static SOrdinarySalesTypeParamConverter getInstance() {
    if (instance == null)
      instance = new SOrdinarySalesTypeParamConverter();
    return instance;
  }

  private static SOrdinarySalesTypeParamConverter instance;

  private SOrdinarySalesTypeParamConverter() {
  }

  @Override
  public SOrdinarySalesTypeParam convert(AOrdinarySalesTypeParam source) {
    if (source == null) {
      return null;
    }
    SOrdinarySalesTypeParam target = new SOrdinarySalesTypeParam();
    target.setCalcUnit(source.getCalcUnit());
    target.setDate(source.getDate());
    target.setStores(new ArrayList<String>());
    target.getStores().addAll(source.getStores());
    target.setType(source.getType());
    return target;
  }

}
